package controllers;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import data.PageData;

import models.PageModel;


public class QuestionServlet extends HttpServlet{
	public void doGet(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException {
		
		String s = (String) request.getParameter("s");
		if (s == null) {
			s = "question-answer";
		}
		
		PageData pageData = new PageData();
		PageModel buyingGuide = pageData.getBuyingGuide();
		PageModel questionAnswer = pageData.getQuestionAnswer();
		PageModel whatisGroupon = pageData.getWhatIsGroupon();
		
		request.setAttribute("buyingGuide", buyingGuide);
		request.setAttribute("questionAnswer", questionAnswer);
		request.setAttribute("whatisGroupon", whatisGroupon);
		request.setAttribute("s", s);
		try {
			request.getRequestDispatcher("/pages/question.jsp").forward(request, response);
		} catch (ServletException e) {
			//e.printStackTrace();
		}
	}
}
